package com.xxh.chatdemo.controller;


import cn.hutool.core.lang.Dict;
import com.xxh.chatdemo.handler.MessageEventHandler;
import com.xxh.chatdemo.payload.BroadCastRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/send")
public class chatController {
    @Autowired
    MessageEventHandler handler;

    @PostMapping("/broad")
    public Dict broad(@RequestBody BroadCastRequest message){

        if(message.getMessage().equals("")){
           return Dict.create().set("code",500).set("msg","error");
        }else {
            handler.SendBroadCast(message);
            return Dict.create().set("code",200).set("msg","success");
        }
    }
}
